﻿using System.Windows;
using Catel.Articles._03___MVVM.Examples.NestedUserControls;
using Catel.Articles._03___MVVM.Examples.UserControlWithParameter;
using Catel.Articles.Base.Data;
using Catel.Articles.Base.UI.ViewModels;
using Catel.Articles.Base.UI.Windows;

namespace Catel.Articles._03___MVVM
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Application.Startup"/> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.StartupEventArgs"/> that contains the event data.</param>
        protected override void OnStartup(StartupEventArgs e)
        {
            // Call base
            base.OnStartup(e);

            // Create style forwarders
            Catel.Windows.StyleHelper.CreateStyleForwardersForDefaultStyles();

            // Show example window
            ExamplesViewModel viewModel = new ExamplesViewModel("Catel 03 / n - MVVM Framework");

            // Add custom example
            viewModel.Examples.Add(new ExampleInfo("UserControl with parameter", "Construction of UserControl with parameter",
                "Using the DataContext to construct a view model for a UserControl.", null, null, () =>
                                                                                                      {
                                                                                                          CompaniesWindow window = new CompaniesWindow();
                                                                                                          window.ShowDialog();
                                                                                                      }));

            viewModel.Examples.Add(new ExampleInfo("Nested user controls", "Shows how to deal with complex nested user control trees",
                "This example shows how to deal with complex user control trees. The tree actually provided here isn't that complex, but it shows the power of using dynamic view models in combination with controls.\n\nNotice that the child controls are collapsed by default to show that view models are constructed as soon as the controls are loaded (become visible).", null, null, () =>
                {
                    HouseWindow window = new HouseWindow();
                    window.ShowDialog();
                }));

            // Show window
            ExamplesWindow examplesWindow = new ExamplesWindow(viewModel);
            examplesWindow.ShowDialog();
        }
    }
}
